<!doctype html>
<html lang="en" xmlns="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>后台登录-X-admin1.1</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" th:href="@{/css/font.css}">
	<link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>

</head>
<body>
    <!-- 中部开始 -->
    <div class="wrapper">
        <!-- 右侧主体开始 -->
        <div class="page-content">
          <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form">
                <div class="layui-form-item">
                
                
                    <label for="L_username" class="layui-form-label">
                        员工姓名
                    </label>
                    <div class="layui-input-inline">
                     <input type="hidden" id="L_username" name="id" disabled="" th:value="${employee.id}" class="layui-input">
                        <input type="text" id="L_username" name="employeename" disabled="" th:value="${employee.employeename}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red">*</span>旧密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_repass" name="oldpass" required="" lay-verify="required"
                        autocomplete="off" class="layui-input" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>新密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_pass" name="newpass" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        6到16个字符
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red">*</span>确认密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_repass" name="repass" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                   
            
                </div>
         
            </form>
                    <button  class="layui-btn" id="xg" onclick="dw()">
                        修改
                    </button>
                
            <!-- 右侧内容框架，更改从这里结束 -->
          </div>
        </div>
        <!-- 右侧主体结束 -->
    </div>
    <!-- 中部结束 -->
   
</body>
<script type="text/javascript" th:inline="javascript">
           function dw(){
        	   var employee={};
        	   employee.employeename=$("[name='employee']").val();
        	   employee.id=$("[name='id']").val();
        	   employee.oldpass=$("[name='oldpass']").val();
        	   employee.newpass=$("[name='newpass']").val();
        	   employee.repass=$("[name='repass']").val();
 			  
 			  var employeeStr=JSON.stringify(employee);
 			  console.log(employeeStr);
 			  
 			 var urlpath = [[@{/employee/updatepass}]];
 			  $.ajax({
 				  url:urlpath,
 				  data:employeeStr,
 				  type:"post",
 				  processData:false,
 				  contentType:"application/json",
 				  datatype:"text",
 				  success:function(){
 					  alert("修改成功");
 				  },error:function(){
 					 alert("旧密码或两次密码不一致，修改失败！");
 				  }
 			  })
        	   
        	   
        	   
           }


</script>
  
</html>